package type.convert;

/**
 * @Package: type.convert
 * @ClassName: StringToBasic
 * @Author: Alone
 * @CreateTime: 2022/1/28 10:39
 * @Description: String类型转换基础数据类型
 */

public class StringToBasic {
    public static void main(String[] args) {
        String s="123";

        //通过基础数据类型包装类的相应方法转换
        int n1 = Integer.parseInt(s);
        double n2 = Double.parseDouble(s);
        float n3 = Float.parseFloat(s);
        long n4 = Long.parseLong(s);
        byte n5 = Byte.parseByte(s);
        boolean n6 = Boolean.parseBoolean("true");

        System.out.println(n1);
        System.out.println(n2);
        System.out.println(n3);
        System.out.println(n4);
        System.out.println(n5);
        System.out.println(n6);
    }
}
